#include <climits>
#include<vector>
class Gloves {
public:
    int findMinimum(int n, vector<int> left, vector<int> right) {
        // write code here
        int left_sum = 0, left_min = INT_MAX;
        int right_sum = 0, right_min = INT_MAX;
        int sum = 0;
        for (int i = 0; i < n; ++i)
        {
            if (left[i] * right[i] == 0)
            {
                sum += right[i] + left[i];
            }
            else {
                left_sum += left[i];
                left_min = left_min < left[i] ? left_min : left[i];
                right_sum += right[i];
                right_min = right_min < right[i] ? right_min : right[i];
            }
        }

        return sum + 1 + min(left_sum - left_min + 1, right_sum - right_min + 1);
    }
};